<template>
  <div class="wrap">
    <m-header></m-header>
    <div class="content">
      <div class="left">
        <p class="title">{{ articalData.title }}</p>
        <div class="relateInfo">
          <div class="author">
            <span class="iconfont icon-gerenzhongxin1"></span>
            <p>{{ articalData.author }}</p>
          </div>
          <div class="pv">
            <span class="iconfont icon-liulan" style="font-size: 24px"></span>
            <p>{{ articalData.pv }}</p>
          </div>
        </div>
        <v-md-preview :text="articalData.content"></v-md-preview>
      </div>
      <div class="right">
        <div class="title">推荐文章</div>
        <div class="item" v-for="item in recommendList" :key="item.id">
          <a href="/artical?id=1" target="_blank">{{ item.title }}</a>
        </div>
      </div>
    </div>
    <bottom></bottom>
  </div>
</template>

<script>
import mHeader from "@/components/header.vue";
import bottom from "@/components/bottom.vue";
import myContent from "./components/content.vue";
import VMdPreviewHtml from "@kangc/v-md-editor/lib/preview-html";

export default {
  components: {
    mHeader,
    bottom,
    myContent,
    VMdPreviewHtml,
  },
  data() {
    return {
      articalData: {},
      recommendList: {},
    };
  },
  created() {
    let { id } = this.$route.query;
    this.getDataList(id);
    this.getRecommend();
  },
  methods: {
    getDataList(id) {
      this.HttpService.getArticalDetail({ id: id }).then((res) => {
        console.log(res);
        this.articalData = res.data;
      });
    },
    getRecommend() {
      this.HttpService.getRecommend().then((res) => {
        console.log(res);
        this.recommendList = res.data;
      });
    },
  },
};
</script>

<style lang='less' scoped>
.content {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  justify-content: space-around;
  margin-top: 20px;
}
.left {
  background-color: #fff;
  width: 78%;
  .title {
    text-align: center;
    line-height: 50px;
    margin-top: 20px;
    font-size: 28px;
    font-weight: bold;
  }
  .relateInfo {
    display: flex;
    justify-content: center;
    div {
      display: flex;
      align-items: center;
      margin-right: 20px;
      span {
        color: #aaa;
      }
      p {
        color: #aaa;
        margin-left: 5px;
      }
    }
  }
}
.right {
  width: 20%;
  background-color: #fff;
  height: 300px;
  padding: 0px 10px;
  .title {
    font-size: 20px;
    line-height: 50px;
    color: #000;
  }
  .item {
    line-height: 30px;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    a{
      color:#444;
    }
  }
}
</style>
